﻿Imports System.Web.UI.WebControls
Imports System.ComponentModel

<Serializable()> _
Public Class ItemParametro

    Private strTitulo As String
    Private unitLarguraTitulo As Unit
    Private strNomeParametro As String
    Private strListaOpcoes As String
    Private strCssClass As String = "textbox"
    Private strTituloCssClass As String = "label"
    Private eTipoValor As eTipoValor = eTipoValor.Texto
    Private eTipoObjeto As eTipoObjeto = Componentes.eTipoObjeto.TextBoxCarga
    Private lngLinha As Long = 1
    Private lngColuna As Long = 1
    Private strValorPadrao As String
    Private intPosicaoTitulo As ePosicaoTitulo
    Private unitLargura As Unit
    Private bolObrigatorio As Boolean

    <Category("Dados do Parametro"), _
    DefaultValue(GetType(String), ""), _
    DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
    Public Property Titulo() As String
        Get
            Return strTitulo
        End Get
        Set(ByVal Value As String)
            strTitulo = Value
        End Set
    End Property

    <Category("Dados do Parametro"), _
DefaultValue(GetType(String), ""), _
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
Public Property LarguraTitulo() As Unit
        Get
            Return Me.unitLarguraTitulo
        End Get
        Set(ByVal Value As Unit)
            Me.unitLarguraTitulo = Value
        End Set
    End Property

    <Category("Dados do Parametro"), _
    DefaultValue(GetType(String), ""), _
    DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
    Public Property NomeParametro() As String
        Get
            Return strNomeParametro
        End Get
        Set(ByVal Value As String)
            strNomeParametro = Value
        End Set
    End Property

    <Category("Dados do Parametro"), _
  DefaultValue(GetType(String), ""), _
  DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
  Public Property TipoValor() As MDP.Framework.Componentes.eTipoValor
        Get
            Return Me.eTipoValor
        End Get
        Set(ByVal value As MDP.Framework.Componentes.eTipoValor)
            Me.eTipoValor = value
        End Set
    End Property

    <Category("Dados do Parametro"), _
 DefaultValue(GetType(String), ""), _
 DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
 Public Property TipoObjeto() As MDP.Framework.Componentes.eTipoObjeto
        Get
            Return Me.eTipoObjeto
        End Get
        Set(ByVal value As MDP.Framework.Componentes.eTipoObjeto)
            Me.eTipoObjeto = value
        End Set
    End Property

    <Category("Dados do Parametro"), _
DefaultValue(GetType(String), ""), _
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
Public Property Obrigatorio() As Boolean
        Get
            Return Me.bolObrigatorio
        End Get
        Set(ByVal value As Boolean)
            Me.bolObrigatorio = value
        End Set
    End Property

    Public Property ListaOpcoes() As String
        Get
            Return strListaOpcoes
        End Get
        Set(ByVal value As String)
            strListaOpcoes = value
        End Set
    End Property

    Public Property ValorPadrao() As String
        Get
            Return strValorPadrao
        End Get
        Set(ByVal value As String)
            strValorPadrao = value
        End Set
    End Property

    Public Property CssClass() As String
        Get
            Return Me.strCssClass
        End Get
        Set(ByVal value As String)
            Me.strCssClass = value
        End Set
    End Property

    Public Property TituloCssClass() As String
        Get
            Return Me.strTituloCssClass
        End Get
        Set(ByVal value As String)
            Me.strTituloCssClass = value
        End Set
    End Property

    Public Property Linha() As Long
        Get
            Return lngLinha
        End Get
        Set(ByVal value As Long)
            lngLinha = value
        End Set
    End Property

    Public Property Coluna() As Long
        Get
            Return lngColuna
        End Get
        Set(ByVal value As Long)
            lngColuna = value
        End Set
    End Property

    Public Property PosicaoTitulo() As ePosicaoTitulo
        Get
            Return Me.intPosicaoTitulo
        End Get
        Set(ByVal value As ePosicaoTitulo)
            Me.intPosicaoTitulo = value
        End Set
    End Property

    <Category("Dados do Parametro"), _
DefaultValue(GetType(String), ""), _
DesignerSerializationVisibility(DesignerSerializationVisibility.Visible)> _
Public Property LarguraControle() As Unit
        Get
            Return Me.unitLargura
        End Get
        Set(ByVal Value As Unit)
            Me.unitLargura = Value
        End Set
    End Property


    Public Function OpcoesToItemCarga(ByVal strListadeOpcoes As String) As ItemCarga()

        Dim strOpcoes() As String
        Dim Itens() As ItemCarga

        strOpcoes = strListadeOpcoes.Split(";")

        ReDim Itens(strOpcoes.Length - 1)

        For Each strOpcao As String In strOpcoes

            Dim Valor, Texto As String

            If strOpcao.Split(",").Length = 2 Then
                Valor = strOpcao.Split(",")(0)
                Texto = strOpcao.Split(",")(1)
            Else
                Valor = strOpcao
                Texto = strOpcao
            End If

            Itens(Array.IndexOf(strOpcoes, strOpcao)) = New ItemCarga(Texto, Valor, False)

        Next

        Return Itens

    End Function
    Public Sub New()

        Me.strTitulo = ""
        Me.strNomeParametro = ""
        Me.eTipoObjeto = Componentes.eTipoObjeto.TextBoxCarga
        Me.eTipoValor = eTipoValor.Texto
        Me.strListaOpcoes = ""
        Me.PosicaoTitulo = ePosicaoTitulo.LadoEsquerdo
        Me.ValorPadrao = String.Empty
        '        Me.bolObrigatorio = False


    End Sub

End Class
